import request from '@/utils/request'
import { AxiosPromise } from 'axios'

// apiUrl 流程分组
const api = {
	listAll: '/v1/process-category/list-all',
	create: '/v1/process-category/create',
	update: '/v1/process-category/update',
	delete: '/v1/process-category/delete',
	sort: '/v1/process-category/sort'
}
/**
 * 流程分组 - 列表
 */
function flowGroupListAllApi(data: any): AxiosPromise {
	return request({
		url: api.listAll,
		method: 'post',
		data,
		headers: {
			'Menu-code': 'PROCESS_CATEGORY'
		}
	})
}

/**
 * 流程分组 - 新增编辑保存
 */
function flowGroupAddOrEditSaveApi(data: any): AxiosPromise {
	return request({
		url: data.id ? api.update : api.create,
		method: 'post',
		data,
		headers: {
			'Menu-code': 'PROCESS_CATEGORY'
		}
	})
}

/**
 * 流程分组 - 删除
 */
function flowGroupDeleteApi(data: any): AxiosPromise {
	return request({
		url: api.delete,
		method: 'post',
		data,
		headers: {
			'Menu-code': 'PROCESS_CATEGORY'
		}
	})
}

function flowGroupSortApi(data: any): AxiosPromise {
	return request({
		url: api.sort,
		method: 'post',
		data,
		headers: {
			'Menu-code': 'PROCESS_CATEGORY'
		}
	})
}

export default {
	flowGroupListAllApi,
	flowGroupAddOrEditSaveApi,
	flowGroupDeleteApi,
	flowGroupSortApi
}
